p={1:4,2:7,3:3,4:2,5:1,6:5,7:6}
p2={1:4,
    2:3,
    3:2,
    4:1,
    }
x=0
k=1

while k<5:
    x=k
    print('k='+str(k))
    while True:
        print(x)
        x= p2[x]
        if x==k:
            print("--------------")
            break
            
    k=k+1
